<?php

class Ledenlijst extends Controller{
	
	function __construct(){
		parent::Controller();
		$this->load->library('pagination');
		$this->load->model('ledenlijst_model');
		$this->load->model('login_model');
	}
	
	function index(){
		//Basis data
		$ingelogd = $this->login_model->is_ingelogd();
		$per_page = 10;
		$data['titel'] = "Ledenlijst";
		$data['query'] = $this->ledenlijst_model->getUsers($per_page, $this->uri->segment(3));
		
		//Config pagination opzetten
		$config['base_url'] = base_url().'index.php/ledenlijst/index';
		$config['total_rows'] = $this->ledenlijst_model->telUsers();
		$config['per_page'] = $per_page;
		$config['full_tag_open'] = '<p>';
    	$config['full_tag_close'] = '</p>';
    	
    	//Pagination initialiseren
    	$this->pagination->initialize($config);
    	
    	//Als hij is ingelogd laad view
    	if($ingelogd){    	
    		$this->load->view('ledenlijst_view',$data);
		}
		else{
			redirect('login');
		}
	}
}

?>